
/**
 * @param {*} extra 额外参数
 * @return {*} 
 */
function ceateThunkMiddleware(extra) {
    // 返回一个中间件
    return store => next => action => {
        if (typeof action === 'function') {
            return action(store.dispatch, store.getState, extra)
        }
        return next(action)
    }
}

const thunk = ceateThunkMiddleware()
thunk.withExtraArgument = ceateThunkMiddleware

export default thunk